//
//  USTodayTalkView.m
//  us
//
//  Created by lhx on 2025/5/22.
//

#import "USTodayTalkView.h"

@interface USTodayTalkView ()


@end

@implementation USTodayTalkView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self setupView];
    }
    return self;
}

- (void)setupView{
    UIImageView *bgImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"todayTalk"]];
    [self addSubview:bgImgView];
    [bgImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self);
    }];
    
    UILabel *titleLab = [[UILabel alloc]init];
    titleLab.font = [UIFont systemFontOfSize:18 weight:UIFontWeightSemibold];
    titleLab.textColor = UIColor.labelColor;
    titleLab.text = @"每日\n问答";
    titleLab.numberOfLines = 2;
    [self addSubview:titleLab];
    [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(22);
        make.top.mas_offset(32);
    }];
    
    
    UIImageView *leftImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"ic_love_red"]];
    [self addSubview:leftImageView];
    [leftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(titleLab);
        make.bottom.mas_equalTo(titleLab.mas_top).offset(-2);
    }];
    
    UILabel *contentLab = [[UILabel alloc]init];
    contentLab.font = [UIFont systemFontOfSize:15];
    contentLab.textColor = UIColor.secondaryLabelColor;
    contentLab.numberOfLines = 0;
    self.contentLab = contentLab;
    [self addSubview:contentLab];
    
    [contentLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(titleLab.mas_right).offset(24);
        make.right.mas_offset(-12);
        make.centerY.mas_equalTo(titleLab);

    }];
    
    UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(talkAction)];
    self.userInteractionEnabled = YES;
    [self addGestureRecognizer:recognizer];
}

- (void)talkAction {
    if (self.clickTodayTalkBlock) {
        self.clickTodayTalkBlock();
    }
}

@end
